package osx.mantianx.wirte;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.joda.time.DateTime;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author starrysky
 * @title: PoiExecl
 * @projectName Execl_Poi_EasyExecl
 * @description: poi
 * @date 2021/2/408:54
 */
public class PoiExcel {
    public static void main(String[] args) {

        //xls版本03 行数65536
        Workbook book = new HSSFWorkbook();

        Sheet sheet = book.createSheet("kubernetes学习计划表");

        Row row1 = sheet.createRow(0);
        Cell cell1 = row1.createCell(0);
        Cell cell2 = row1.createCell(1);

        cell1.setCellValue("视频名称");
        cell2.setCellValue("视频时长");

        Row row2 = sheet.createRow(1);
        Cell cell3 = row2.createCell(0);
        Cell cell4 = row2.createCell(1);
        cell3.setCellValue("Poi及EasyExcel01");
        cell4.setCellValue(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));

        FileOutputStream excel01 =null;
        try {
           excel01 = new FileOutputStream("excel01.xls");
           book.write(excel01);
            System.out.println("写入完毕");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (excel01!=null){
                try {
                    excel01.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
